package JFrame.Admin.MailManager;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;

import Dao.MailDaoImpl;
import JFrame.*;
public class DeleteMailJFrame extends JFrame {
    JFrame jFrame =this;
    public DeleteMailJFrame() {
        initializing();
    }
    public void initializing(){
        JPanel panel=new JPanel();
        panel.setLayout(new GridLayout(2,2,10,10));
        panel.setBorder(new EmptyBorder(20, 20, 20, 20));
        add(panel);
        panel.setBackground(new Color(255, 255, 255));
        JLabel l_id =new JLabel("请输入要删除的快件ID:",SwingConstants.CENTER);
        JTextField t_id =new JTextField(SwingConstants.CENTER);
        JButton Yes =new JButton("确认");
        JButton Cancel =new JButton("取消");
        Yes.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new MailDaoImpl().Delete(t_id.getText());
            }
        });
        Cancel.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                jFrame.dispose();
            }
        });
        Cancel.setBackground(new Color(102,204,255));
        Yes.setBackground(new Color(102,204,255));

        setSize(600,200);
        setTitle("删除快件——管理员");
        setResizable(false);
        setLocationRelativeTo(getOwner());
        Tools.setFonts(20,1,l_id,Yes,Cancel);
        Tools.setFonts(15,0,t_id);
        Tools.setTextFieldCenter(t_id);
        Tools.addComponents(panel,l_id,t_id,Yes,Cancel);
        setVisible(true);
    }
}
